-
Notifications
You must be signed in to change notification settings - Fork 1k
I2C IT mode #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I2C IT mode #135
Conversation
This reverts commit 625fe2d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall : Looks good to me !
Only 2 questions raised during review
cores/arduino/stm32/twi.c
Outdated
@@ -101,7 +101,7 @@ | |||
*/ | |||
|
|||
/* Family specific description for I2C */ | |||
#define I2C_NUM (5) | |||
#define I2C_NUM (4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this value be defined in the family / target specific files ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be something like this:
#if defined(STM32F7xx) || defined(STM32L4xx)
#define I2C_NUM (4)
#elif defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32L1xx)
#define I2C_NUM (2)
#else // STM32F2xx || STM32F3xx || STM32F4xx || STM32L0xx
#define I2C_NUM (3)
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
i2c_t *obj = get_i2c_obj(hi2c); | ||
|
||
if(obj->isMaster == 0) { | ||
HAL_I2C_EnableListen_IT(hi2c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you comment or explain this ErrorCallback management ?
If there is an error, shouldn't we report the error to application ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In master mode, the callback is useless because the error is reported to the Arduino API with i2c_master_write()
and i2c_master_read()
.
In slave mode, there is no mechanism in Arduino API to report an error so the error callback forces the slave to listen again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok Good. So please explain this either with comments in the code, or in the commit message, this is useful information that we cannot guess when reading the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - good - I see it now !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above in the header of the function.
|
||
obj->irq = I2C1_EV_IRQn; | ||
#if !defined(STM32F0xx) && !defined(STM32L0xx) | ||
obj->irqER = I2C1_ER_IRQn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one new proposal : in every place where I2Cx_ER_IRQn is being used couldn't you use
#if defined (I2C1_ER_IRQn)
obj->irqER = I2C1_ER_IRQn;
#endif
this would be more future proof I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I2C1_ER_IRQn is a enum value this could not be done.
cores/arduino/stm32/twi.c
Outdated
#elif defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32L1xx) | ||
#define I2C_NUM (2) | ||
#else // STM32F2xx || STM32F3xx || STM32F4xx || STM32L0xx | ||
#define I2C_NUM (3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you thin about
#elif defined( STM32F2xx) || defined(STM32F3xx) || defined(STM32F4xx) || #defined(STM32L0xx)
#else
#error Unknown Family - unknown I2C_NUM
#endif
so that 3 is not the default for any new family and we will be remonded to complete this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
i2c_t *obj = get_i2c_obj(hi2c); | ||
|
||
if(obj->isMaster == 0) { | ||
HAL_I2C_EnableListen_IT(hi2c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - good - I see it now !
Signed-off-by: fpr <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting #131 approval before merge
Issue #123 fixed.